<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 
    <h:head></h:head> 
    <body> 
        <p:layout fullPage="true">  
  
         <p:layoutUnit position="north" size="120" style =" text-align : center;"  > 
    		<style type="text/css">
        	.ui-widget{font-size:90% !important;}  
      		</style> 
      		<a href="http://localhost:8080/TravelDreamFelConRusWeb/employee/employeehome.xhtml">
         <p:graphicImage  value="logo.jpg" style=" height:100px;" />
         </a>
		</p:layoutUnit>  
     
      
        <p:layoutUnit position="west" size="200" header="Pagine utili" resizable="false" closable="false" collapsible="false">   
            <p:menu>  
               
                     <p:menuitem value="Pacchetti" url="http://localhost:8080/TravelDreamFelConRusWeb/employee/packageManagement.xhtml" />  
                     <p:menuitem value="Pagina personale" url="http://localhost:8080/TravelDreamFelConRusWeb/employee/employeePersonal.xhtml" />  
           
            </p:menu>   
        </p:layoutUnit>  
      
         <p:layoutUnit position="south" size="50"  resizable="false" closable="false" collapsible="false">  
         <h:form style =" text-align : center;">
           <p:button outcome="/employee/employeePersonal.xhtml" value="Ok, fatto"  icon="ui-icon-arrowrefresh-1-w" ></p:button>
         </h:form>  
        </p:layoutUnit>  
      
      <p:layoutUnit position="center">  
	  <h:form id="form">
 <p:dataTable var="flight" value="#{flightManagement.flightModel}" rowKey="#{flight.idProduct}" paginator="true" rows="10"  
                selection="#{flightManagement.selectedFlight}" selectionMode="single" 
                filteredValue="#{flightManagement.filteredFlights}" id="flighttable"
                 rowsPerPageTemplate="10,15,50">  
   
  
                <f:facet name="header">
                    Voli
                </f:facet>  
                
                    <p:column  headerText="Nome" sortBy="#{flight.name}" filterBy="#{flight.name}" id="name">
                    
                    <p:commandLink value="#{flight.name}" update=":modForm:display" oncomplete="modDialog.show()"  title="View">
                        <f:setPropertyActionListener value="#{flight}" target="#{flightManagement.selectedFlight}" />    
                    </p:commandLink>
                    
                	</p:column>
                	
                    <p:column  headerText="Creatore" sortBy="#{flight.employeeCreator}" filterBy="#{flight.employeeCreator}" id="employeeCreator">
                      #{flight.employeeCreator}  
                      </p:column>    
                       <p:column  headerText="Area di partenza" sortBy="#{flight.area_start}" filterBy="#{flight.area_start}" id="areaStart">
                      #{flight.area_start} 
                       </p:column>                       
                       <p:column  headerText="Area di arrivo" sortBy="#{flight.area}" filterBy="#{flight.area}" id="area">
                      #{flight.area}  
                      </p:column>                       
                       <p:column  headerText="Luogo di partenza" sortBy="#{flight.place_start}" filterBy="#{flight.place_start}" id="placeStart">  
                      #{flight.place_start}  
                      </p:column>
                      <p:column  headerText="Luogo di arrivo" sortBy="#{flight.place_end}" filterBy="#{flight.place_end}" id="placeEnd">  
                      #{flight.place_end}  
                      </p:column> 
                       <p:column  headerText="Ora di partenza" sortBy="#{flight.timeStart}" filterBy="#{flight.timeStart}" id="timeStart">  
                      #{flight.timeStart}  
                      </p:column> 
                       <p:column  headerText="Ora di arrivo" sortBy="#{flight.timeEnd}" filterBy="#{flight.timeEnd}" id="timeEnd">  
                      #{flight.timeEnd}  
                      </p:column>  
                       <p:column  headerText="Compagnia" sortBy="#{flight.flight_company}" filterBy="#{flight.flight_company}" id="flight_company">  
                      #{flight.flight_company}  
                      </p:column> 
                      <p:column  headerText="Informazioni" sortBy="#{flight.more_info}" filterBy="#{flight.more_info}" id="more_info">  
                      #{flight.more_info}  
                      </p:column> 
                     <p:column  headerText="Costo" sortBy="#{flight.cost}" filterBy="#{flight.cost}" id="cost">  
                      #{flight.cost}  
                      </p:column> 
                      <p:column  headerText="Stato" sortBy="#{flight.state}" filterBy="#{flight.state}" id="state">  
                      #{flight.state}  
                      </p:column> 
  
               <f:facet name="footer">
                    <p:commandButton  value="Aggiungi nuovo" onclick="PF('dlg3').show();" type="button" icon="ui-icon-star"/> 
                    
                    <p:commandButton value="Elimina" actionListener="#{flightManagement.deleteFlight}" oncomplete="PF('delMess').show();" update="flighttable" icon="ui-icon-trash"/> 
                         
                </f:facet>          
              </p:dataTable>
                
         </h:form>   
         
        
    
        </p:layoutUnit>  
      
        </p:layout> 
         
          <p:dialog header="Inserisci i dati del nuovo volo" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" resizable="false">  
     <h:form>
     <h:panelGrid columns="2" cellpadding="5">  
     
           <h:outputLabel for="newname" value="Nome:" />  
            <p:inputText value="#{flightManagement.name}" id="newname" required="true" label="newname" /> 
                     
            <h:outputLabel for="newarea" value="Area di partenza:" />  
            <p:inputText value="#{flightManagement.area_start}" id="newarea_start" required="true" label="newarea_start" />
            
             <h:outputLabel for="newarea" value="Area di arrivo:" />  
            <p:inputText value="#{flightManagement.area}" id="newarea" required="true" label="newarea" />
            
            <h:outputLabel for="newplace" value="Luogo di partenza:" />  
            <p:inputText value="#{flightManagement.place_start}" id="newplace_start" required="true" label="newplace_start" />  
            
            <h:outputLabel for="newplace" value="Luogo di arrivo:" />  
            <p:inputText value="#{flightManagement.place_end}" id="newplace_end" required="true" label="newplace_end" />  
            
            <h:outputLabel for="newtimeStart" value="Ora partenza:" />  
            <p:calendar id="newtimeStart" value="#{flightManagement.timeStart}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy HH:mm" showOn="button" readonlyInput="true" label="newtimeStart"/>
            
            <h:outputLabel for="newtimeEnd" value="Ora arrivo:" />  
             <p:calendar id="newtimeEnd" value="#{flightManagement.timeEnd}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy HH:mm" showOn="button" readonlyInput="true" label="newtimeEnd"/>
			
			<h:outputLabel for="newcompany" value="Compagnia:" />  
            <p:inputText value="#{flightManagement.flight_company}" id="newcompany" required="true" label="newcompany" />
            
            <h:outputLabel for="newmore_info" value="Informazioni:" />  
            <p:inputText value="#{flightManagement.more_info}" id="newmore_info" required="true" label="newmore_info" />
            
            <h:outputLabel for="newcost" value="Costo:" />  
            <p:inputText value="#{flightManagement.cost}" id="newcost" required="true" label="newcost" />
            
            <f:facet name="footer">  
                <p:commandButton id="createButton" value="Crea" update=":form:flighttable"   
                    actionListener="#{flightManagement.newFlight}"  
                   oncomplete="dlg3.hide();"/>         
               
            </f:facet>  
        </h:panelGrid>  
        </h:form>
        
             
        	</p:dialog> 
        	
        <script type="text/javascript">  
    function handleLoginRequest(xhr, status, args) {  
        if( !args.loggedIn) {  
            PF('dlg3').jq.effect("shake", { times:5 }, 100);  
        }   
        else {  
            PF('dlg3').hide();  
            $('#loginLink').fadeOut();  
        }  
    }  
</script>  	
    
       <p:dialog header="Modifica i dati del volo" widgetVar="modDialog" resizable="false" id="modDlg" > 
               <h:form id="modForm">
               <p:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">
                  
			<h:outputText value="Nome:"></h:outputText>
                        <h:outputText value="#{flightManagement.selectedFlight.name}" />
            <h:outputText value="Nuovo nome:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.name}"/>			
						
			<h:outputText value="Area di partenza:"></h:outputText>			
						<h:outputText value="#{flightManagement.selectedFlight.area_start}" />
			<h:outputText value="Nuova area di partenza:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.area_start}"/>
						
			<h:outputText value="Area di arrivo:"></h:outputText>			
						<h:outputText value="#{flightManagement.selectedFlight.area}" />
			<h:outputText value="Nuova area partenza:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.area}"/>
						
            <h:outputText value="Luogo di partenza:"></h:outputText>
						<h:outputText value="#{flightManagement.selectedFlight.place_start}" />
			<h:outputText value="Nuovo luogo di partenza:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.place_start}"/>
						
	        <h:outputText value="Luogo di arrivo:"></h:outputText>
						<h:outputText value="#{flightManagement.selectedFlight.place_end}" />
			<h:outputText value="Nuovo luogo:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.place_end}"/>				
						
		    <h:outputText value="Ora partenza:"></h:outputText>
                        <h:outputText value="#{flightManagement.selectedFlight.timeStart}" />
            <h:outputText value="Nuova ora inizio:"></h:outputText>
						<p:calendar id="modtimeStart" value="#{flightManagement.selectedFlight.timeStart}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy HH:mm" showOn="button" readonlyInput="true" label="newtimeStart"/>
						
			<h:outputText value="Ora arrivo:"></h:outputText>
                        <h:outputText value="#{flightManagement.selectedFlight.timeEnd}" />
            <h:outputText value="Nuova ora fine:"></h:outputText>
						<p:calendar id="modtimeEnd" value="#{flightManagement.selectedFlight.timeEnd}" 
			navigator="true" required="true" yearRange="c-100:c-0"
			pattern="MM/dd/yyyy HH:mm" showOn="button" readonlyInput="true" label="newtimeEnd"/>
												
			<h:outputText value="Compagnia:"></h:outputText>
                        <h:outputText value="#{flightManagement.selectedFlight.flight_company}" />
            <h:outputText value="Nuova compagnia:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.flight_company}"/>
						
		    <h:outputText value="Informazioni:"></h:outputText>
                        <h:outputText value="#{flightManagement.selectedFlight.more_info}" />
            <h:outputText value="Nuove informazioni:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.more_info}"/>
						
			<h:outputText value="Costo:"></h:outputText>
                        <h:outputText value="#{flightManagement.selectedFlight.cost}" />
            <h:outputText value="Nuovo costo:"></h:outputText>
						<h:inputText value="#{flightManagement.selectedFlight.cost}"/>
						
      		<f:facet name="footer">
                     
                            <p:commandButton value="Salva modifiche" update=":form:flighttable"  
                            oncomplete="modDialog.hide(); PF('modMess').show(); " actionListener="#{flightManagement.updateFlight}"/>
                            
                    </f:facet>
			
                </p:panelGrid> 
             </h:form>
          </p:dialog> 
          
          <p:dialog header="Eliminazione" widgetVar="delMess" showEffect="explode" hideEffect="bounce" resizable="false"
                   width="200" height="100" dynamic="true">      
             #{flightManagement.messageDelete}
         </p:dialog>
         
        <p:dialog header="Modifica" widgetVar="modMess" showEffect="explode" hideEffect="bounce" resizable="false"
                   width="200" height="100" dynamic="true">      
            #{flightManagement.messageModify}
         </p:dialog>
                                 
      
<p:growl id="growl" showDetail="true" life="5000" />
         
 
    </body> 
    
    
</html>